import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:rebase_project/generated/l10n.dart';
import 'package:rebase_project/res/style.dart';
import 'package:rebase_project/src/base/widget/Button.dart';
import 'package:rebase_project/src/base/widget/defalut_page_state_widget.dart';
import 'package:rebase_project/src/module/Test4Widget.dart';
import 'package:rebase_project/src/module/item/item_mmp.dart';
import 'package:rebase_project/src/provider/Mmp2Notify.dart';
import 'package:rebase_project/src/provider/MmpNotify.dart';
import 'package:caose/export/caose_widget.dart';
import 'package:amap_map_fluttify/amap_map_fluttify.dart';

//
class TestWidget extends StatefulWidget with CreateProvider<MmpNotify> {
  @override
  _TestWidgetState createState() => _TestWidgetState();

  @override
  createSingleValue(BuildContext context) {
    return MmpNotify();
  }
}

class _TestWidgetState extends State<TestWidget>
    with BaseWidget<TestWidget, MmpNotify>, DefalutPageStateWidgetMixin {
  @override
  Future initData() async {
    return mController.getMmpData();
  }

  @override
  Widget initView(BuildContext context) {
    return Container(
      width: double.infinity,
      height: double.infinity,
      child: Stack(
        alignment: Alignment.center,
        children: <Widget>[
          Button(
            color: Colors.redAccent,
            padding:
                EdgeInsets.symmetric(vertical: dip(10), horizontal: dip(30)),
            onPressed: mController.regist,
            child: Text(
              S.of(context).regist,
              style: text_fff_13,
            ),
          ),
        ],
      ),
    );
  }

  @override
  Widget title(BuildContext context) {
    return CNavigatorBar.create(title: S.of(context).main, showBack: false)
        .build(context);
  }
}

class TestMmpWidget extends StatelessWidget
    with
        CunwStlessWidget<Mmp3Notify>,
        DefalutPageStateWidgetMixin,
        NavigatorActionMixin2 {
  @override
  Widget initView(BuildContext context) {
    // TODO: implement initView
//    SliverGridDelegateWithFixedCrossAxisCount
//    GridView.count(crossAxisCount: 3);
    return Container(
      width: double.infinity,
      height: double.infinity,
      alignment: Alignment.center,
      child: Dazzle2().customScrollView([
        MoreDataWidget(),
        MmpItem(),
        MmpItem2(),
        MmpItem4(),
        MmpItem3(),
        NoMoreWidget(),
        NoDataWidget(mainPixel: 10),
      ], dataList: [
        "",
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        false,
        1.0,
        1.0
//        NoMoreData()
      ]),
    );
  }

  @override
  Widget title(BuildContext context) {
    // TODO: implement title
    return null;
  }

  @override
  Future onRetry(BuildContext context) {
    return Provider.of<Mmp3Notify>(context, listen: false).load();
  }

  @override
  Mmp3Notify createSingleValue(BuildContext context) {
    // TODO: implement createSingleValue
    return Mmp3Notify()..complete();
  }
}
